import { Http, Headers, Response,Jsonp, RequestOptions, URLSearchParams } from '@angular/http';
import 'rxjs/add/operator/toPromise';

import { Injectable } from '@angular/core';

import { Payreport } from './payreport';
import { SERVER} from '../../app.config';

@Injectable()
export class PayreportService {

    constructor(private http: Http){

    }

    searchPayreports(start_time: string, end_time: string): Promise<Payreport[]> {
        let url = SERVER.REPORT + "/pay?start_time=" + start_time + '&end_time=' + end_time;
        return this.http.get(url)
        .toPromise()
        .then(response => response.json() as Payreport[])
        .catch(this.handleError);
    }

    private handleError(error: any): Promise<any> {
        console.error('错误：', error);

        return Promise.reject(error.message || error);
    }
}